using System;
using UnityEngine;

[Serializable]
public class TTCameraBehaviourServeCamera : TTCameraBehaviour
{
	public Vector3 offsetFromPlayer;

	public Vector3 lookAtPosition;

	public float offsetYScale;

	public float lookAtScale;

	public float offsetXScale;

	protected TableTennisHumanPlayer humanPlayer;

	public override void Start(Camera cam, TTCameraController camController, TTCameraOptions cameraOptions)
	{
		base.Start(cam, camController, cameraOptions);
		humanPlayer = cameraOptions.player as TableTennisHumanPlayer;
	}

	public override void Update()
	{
		if (!(humanPlayer == null))
		{
			Vector3 vector = offsetFromPlayer;
			vector.z *= humanPlayer.tableSide;
			Vector3 vector2 = humanPlayer.transform.position.OnGround() + vector;
			Vector3 position = humanPlayer.match.ball.position;
			vector2.y += position.y * offsetYScale;
			Vector3 vector3 = lookAtPosition;
			vector3.x += position.x * offsetXScale;
			vector3.y += position.y * lookAtScale;
			Quaternion b = Quaternion.LookRotation(vector3 - vector2);
			camera.transform.position = Vector3.Lerp(camera.transform.position, vector2, RealTime.deltaTime * moveSpeed);
			camera.transform.rotation = Quaternion.Lerp(camera.transform.rotation, b, RealTime.deltaTime * rotationSpeed);
			camera.fieldOfView = Mathf.Lerp(camera.fieldOfView, fov, RealTime.deltaTime * rotationSpeed);
		}
	}
}
